﻿using FB.Data.Models;
using FB.Enums;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FB.Providers.AEInfo
{
    public enum AEAssistantType
    {
        Other = 0,
        Staff = 1,
    }

    public class AEAssistant : FBAuditModel, IRecordState, IPersonalInfo, IFullName
    {
        [Key, DatabaseGenerated(System.ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption.Identity)]
        public int ID { get; set; }

        [Required]
        public long AEID { get; set; }

        [StringLength(16)]
        public string RefCode { get; set; }

        public AEAssistantType AEAssistantType { get; set; }
        
        [StringLength(256)]
        public string LastName { get; set; }

        [StringLength(256)]
        public string FirstName { get; set; }

        [StringLength(256)]
        public string Alias { get; set; }

        [StringLength(256), Column("CHNName")]
        public string ChineseName { get; set; }


        [NotMapped]
        public string FullName
        {
            get
            {
                var f = new StringBuilder();
                if (!string.IsNullOrEmpty(LastName)) f.AppendFormat("{0} ", LastName);
                if (!string.IsNullOrEmpty(FirstName)) f.AppendFormat("{0} ", FirstName);
                if (!string.IsNullOrEmpty(Alias)) f.AppendFormat("{0} ", Alias);
                if (!string.IsNullOrEmpty(ChineseName)) f.AppendFormat("{0} ", ChineseName);

                return f.ToString();
            }
        }

        public RecordState RecordState { get; set; }

        public int? LocationID { get; set; }

        [ForeignKey("LocationID")]
        public virtual Location Location { get; set; }

    }
}
